<?
require_once("lib/php/controller/ViewController.php");
require_once("lib/php/Json.php");
require_once("ericdingle/php/Authentication.php");
require_once("ericdingle/model/post/PostProvider.php");
require_once("ericdingle/model/photo/PhotoProvider.php");

class ViewAlbum extends ViewController {
	public function doGet() {
		// get authentication
		$auth = Authentication::getInstance();
	
		// get post
		$postID = $_GET["postID"];
		if (!$postID) {
			header("Location: viewPosts");
			exit();
		}

		$postProvider = PostProvider::getInstance();
		$post = $postProvider->readByPostID($postID);

		// get photos
		$photoProvider = PhotoProvider::getInstance();
		$photos = $photoProvider->readByPostID($postID);
		
		// load views
		require_once("ericdingle/php/Tabs.php");
		$this->loadView("ericdingle/view/header.php", array(
			"isLoggedIn" => $auth->isLoggedIn(),
			"tabID" => TabID::BLOG,
			"tabs" => $tabs,
			"css_files" => array(
				"css/viewAlbum.css",
				"/thirdparty/lightbox/css/lightbox.css"
			),
			"js_files" => array(
				"/thirdparty/lightbox/js/prototype.js",
				"/thirdparty/lightbox/js/scriptaculous.js?load=effects,builder",
				"/thirdparty/lightbox/js/lightbox.js"
			)
		));
		$this->loadView("ericdingle/view/viewAlbum.php", array(
			"isLoggedIn" => $auth->isLoggedIn(),
			"post" => $post,
			"photos" => $photos
		));
		$this->loadView("ericdingle/view/footer.php");
	}
}
?>
